<template>
    <div>
      <el-form label-width="80px" :inline="true" style="margin-top: 20px">
        <el-form-item label="起始时间">
          <el-date-picker type="datetime" class="w185" value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择日期" v-model="searchObj.startTime">

          </el-date-picker>
        </el-form-item>
        <el-form-item label="结束时间">
          <el-date-picker type="datetime" class="w185" value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择日期" v-model="searchObj.endTime">

          </el-date-picker>
        </el-form-item>
        <el-form-item label="客户名称">
          <el-select v-model="searchObj.customerNo" placeholder="请选择">
            <el-option  :key="1" label="江铃股份" value="1">

            </el-option>
            <el-option  :key="2" label="江铃控股" value="2">

            </el-option>
          </el-select>
        </el-form-item>
        <!-- <el-form-item label="订单号">
          <el-input v-model="searchObj.sysOrderNo" placeholder="请输入内容" class="w185"></el-input>
        </el-form-item> -->
        <el-form-item>
          <el-button style="margin-left:20px " type="primary" @click =search>
            拉取
          </el-button>
        </el-form-item>
      </el-form>
      <loading v-if="loadingFlag">

      </loading>
    </div>
</template>

<script>
  import * as handleAPI from '@/api/handle'
  import Loading from '@/components/loading/loading.vue'
  export default {
    name: 'order',
    components: {
      Loading
    },
    data() {
      return {
        loadingFlag: false,
        searchObj: {
          startTime: '',
          endTime: '',
          customerNo: ''
  
        }
      }
    },
    methods: {
      search() {
        const that = this
        const a = new Date(that.searchObj.startTime).getTime()
        const b = new Date(that.searchObj.endTime).getTime()

        const c = that.searchObj.startTime
        const d = that.searchObj.endTime
        const e = that.searchObj.customerNo
        // const f = that.searchObj.sysOrderNo
        if (!c || !d || e === '') {
          this.$message({
            message: '起始时间，结束时间，客户名称都要填写！',
            type: 'info'
          })
        } else {
          if (!a || !b || b - a >= 0) {
            that.loadingFlag = true
            handleAPI.getOrder(that.searchObj).then(res => {
              that.loadingFlag = false
              if (res.code === 0) {
                this.$message({
                  message: res.message,
                  type: 'success'
                })
              } else {
                this.$message({
                  message: res.message,
                  type: 'error'
                })
              }
            })
          } else {
            that.$message.error('结束时间需大于起始时间！')
          }
        }
      }
    }
  }
</script>

<style scoped>

</style>
